/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: #333;
    overflow-x: hidden;
}

/* Container with responsive height */
.container {
    width: 100%;
    height: 450px; /* Default iframe height */
    max-height: 450px;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Adjust height for full browser view */
@media (min-height: 500px) {
    body:not(.iframe-mode) .container {
        height: 90vh;
        max-height: 90vh;
    }
}

/* Header tooltip */
.header-tooltip {
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
    max-width: 90%;
    text-align: center;
}

.container:hover .header-tooltip {
    opacity: 1;
}

/* Status bar */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 2px solid #ddd;
    font-weight: 600;
    font-size: 14px;
    min-height: 40px;
}

.score {
    color: #e74c3c;
}

.current-mode {
    color: #3498db;
}

/* Main game area */
.game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: white;
}

/* Character panel */
.character-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 15px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.panel-header h3 {
    font-size: 16px;
    color: #2c3e50;
    margin: 0;
}

.toggle-buttons {
    display: flex;
    gap: 5px;
}

.toggle-btn {
    padding: 8px 16px;
    border: 2px solid #3498db;
    background: white;
    color: #3498db;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 12px;
    transition: all 0.3s ease;
    min-height: 36px;
}

.toggle-btn.active,
.toggle-btn:hover {
    background: #3498db;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
}

/* Character grid */
.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
}

.character-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px solid #dee2e6;
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

.character-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    border-color: #3498db;
}

.character-card.interviewed {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border-color: #28a745;
}

.character-card.matched {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border-color: #ffc107;
    opacity: 0.7;
    cursor: not-allowed;
}

.character-name {
    font-weight: 700;
    font-size: 13px;
    color: #2c3e50;
    margin-bottom: 4px;
}

.character-subtitle {
    font-size: 11px;
    color: #6c757d;
    font-style: italic;
}

.character-emoji {
    font-size: 20px;
    margin-bottom: 5px;
}

/* Interview panel */
.interview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 15px;
}

.interview-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.back-btn {
    padding: 8px 12px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
    min-height: 36px;
}

.back-btn:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.character-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.character-name {
    font-weight: 700;
    font-size: 16px;
    color: #2c3e50;
}

.character-type {
    font-size: 12px;
    color: #6c757d;
    font-style: italic;
}

.interview-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
}

.character-statement {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #3498db;
    font-style: italic;
    font-size: 14px;
    line-height: 1.4;
}

.dialogue-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dialogue-btn {
    padding: 12px 15px;
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    font-size: 13px;
    line-height: 1.3;
    transition: all 0.3s ease;
    min-height: fit-content;
    word-wrap: break-word;
}

.dialogue-btn:hover {
    border-color: #3498db;
    background: #f8f9fa;
    transform: translateX(5px);
}

.dialogue-btn.selected {
    background: #3498db;
    color: white;
    border-color: #2980b9;
}

.character-response {
    background: #e8f5e8;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #28a745;
    font-size: 14px;
    line-height: 1.4;
    animation: fadeIn 0.5s ease;
}

/* Matching panel */
.matching-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 15px;
}

.matching-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.matching-header h3 {
    font-size: 16px;
    color: #2c3e50;
    margin: 0;
}

.matching-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.selected-characters {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.selected-culprit,
.selected-victim {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    min-width: 120px;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.match-arrow {
    font-size: 24px;
    font-weight: bold;
    color: #3498db;
}

.confirm-match-btn {
    padding: 12px 24px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    min-height: 44px;
}

.confirm-match-btn:hover:not(:disabled) {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.confirm-match-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Results panel */
.results-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.results-content {
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.results-content h2 {
    color: #28a745;
    margin-bottom: 20px;
    font-size: 24px;
}

.final-score {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 15px;
}

.matches-summary {
    background: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.4;
}

.restart-btn {
    padding: 12px 24px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    min-height: 44px;
}

.restart-btn:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    max-width: 200px;
    word-wrap: break-word;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .character-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 8px;
    }
    
    .character-card {
        padding: 10px;
        min-height: 70px;
    }
    
    .character-name {
        font-size: 12px;
    }
    
    .character-subtitle {
        font-size: 10px;
    }
    
    .dialogue-btn {
        padding: 10px 12px;
        font-size: 12px;
    }
    
    .selected-characters {
        flex-direction: column;
        gap: 15px;
    }
    
    .match-arrow {
        transform: rotate(90deg);
    }
}

/* Scrollbar styling */
.character-grid::-webkit-scrollbar,
.interview-content::-webkit-scrollbar {
    width: 6px;
}

.character-grid::-webkit-scrollbar-track,
.interview-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.character-grid::-webkit-scrollbar-thumb,
.interview-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.character-grid::-webkit-scrollbar-thumb:hover,
.interview-content::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}